home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Games of Daze
/
Infomagic - Games of Daze (Summer 1995) (Disc 1 of 2).iso
/
x2ftp
/
msdos
/
docs
/
fpgawkii
/
pldasm1.pds
< prev
next >
Wrap
Text File
|
1995-03-06
|
3KB
|
81 lines
TITLE XESS PLDasm example
AUTHOR Dave Van den Bout
COMPANY XESS Corp.
DATE 3/6/95
REVISION 4.0
PATTERN ----
DEFMOD led(d[0:1],s[0:6])
CHIP led INTEL_ARCH ; device-independent target
PIN d[0:1] ; 2-bit input in range [0-3]
PIN s[0:6] ; 7-bit LED segment drivers
T_TAB(d1 d0 >> s0 s1 s2 s3 s4 s5 s6)
0 0 : 1 1 1 0 1 1 1 ; LED=0
0 1 : 0 1 0 0 1 0 0 ; LED=1
1 0 : 1 0 1 1 1 0 1 ; LED=2
1 1 : 1 1 0 1 1 0 1 ; LED=3
ENDMOD ; end the module definition
OPTIONS
TURBO = ON
SECURITY = OFF
CHIP example IFX780_84 ; target the NFX780 FPGA
NODE cnt[0:1] REG ; 2-bit counter DFF (buried)
PIN out[0:6] ; LED digit drivers
PIN rst_ CMOS_LEVEL ; CMOS levels and pullups
PIN go CMOS_LEVEL ; on these two inputs
PIN dir TTL_LEVEL ; TTL levels and no pullups
PIN clk TTL_LEVEL ; on these two inputs
PIN equ ; comparator output
PIN err OPEN_DRAIN ; open-drain error output
PIN wr_ ; active-low RAM write-enable
PIN data[3:0] RAM ; 128x4 bit RAM
RAM_DEFAULTS data DEFAULT_VALUE 0xB
[0x0:0x2] : 0x3 ; initialize the
0x3 : 0x5 ; data ram
; connect inputs and outputs to the LED module
MODULE led(d[0:1]=cnt[0:1],s[0:6]=out[0:6])
STATE MOORE_MACHINE ; state machine definition
DEFAULT_BRANCH HOLD_STATE
s0 = /cnt1 * /cnt0 ; define states s0=00
s1 = /cnt1 * cnt0 ; s1=01
s2 = cnt1 * /cnt0 ; s2=10
s3 = cnt1 * cnt0 ; s3=11
s0:= up ->s1 + down ->s3 ; these describe the
s1:= up ->s2 + down ->s0 ; state transitions that
s2:= up ->s3 + down ->s1 ; depend upon the input
s3:= up ->s0 + down ->s2 ; conditions shown below
CONDITIONS
up = dir * go ; count up if dir=1 and enabled
down = /dir * go ; count down if dir=1
EQUATIONS ; Boolean equations start here
cnt[0:1].ACLK = clk ; attach the clock and reset
cnt[0:1].RSTF = /rst_ ; inputs to the flip-flops
data[0:1].ADDR = cnt[0:1] ; address data with cnt
data[1:0].DATA = cnt[0:1] ; and store reversed cnt
wr_ = /(dir * clk) ; data write line pulses low
/data.WE = wr_ ; when dir=1 and clk=1
data.TRST = VCC ; enable data ram outputs
/data.BE = GND ; enable data ram block
err := VCC ; err flip-flop turns on if
err.RSTF = /rst_ ; ram output doesn't match
err.ACLK = /dir * /clk * /equ ; reversed cnt value
equ.CMP = [cnt[0:1]] == [data[1:0]] ; equality compare
SIMULATION
VECTOR count := [cnt1,cnt0]
TRACE_ON count clk
SETF /rst_ dir /clk go ; init inputs
PRLDF cnt1 cnt0 ; init flip-flops
CLOCKF clk ; clock once to reset flip-flops
SETF rst_ ; release reset input
FOR i:=1 TO 4 DO ; clock 4 times
BEGIN CLOCKF clk END
SETF /dir ; now count down
WHILE(count/=1) DO ; until cnt is 1
BEGIN CLOCKF clk END
CHECK /err ; err flag should be 0
TRACE_OFF